﻿using System.Collections.Generic;
using UnityEngine.EventSystems;

namespace Nomo.UnityCoreModule.NodeBehaviours
{
    /// <summary>
    /// 界面的容器。
    /// </summary>
    public sealed class NodeBehaviourContainer : UIBehaviour
    {
        internal readonly List<NodeBehaviour> NodeBehaviours = new List<NodeBehaviour>();

        private void OnTransformChildrenChanged()
        {
            var childCount = transform.childCount;
            for (var i = childCount - 1; i >= 0; i--)
            {
                var child         = transform.GetChild(i);
                var nodeBehaviour = child.GetComponent<NodeBehaviour>();
                if (nodeBehaviour != null)
                {
                    NodeBehaviours.Add(nodeBehaviour);
                }
            }
        }
    }
}
